cmake_minimum_required(VERSION 3.20)
project(quickjspp LANGUAGES C)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

set(qjs_src cutils.h
        cutils.c
        libregexp.c
        libunicode.c
        quickjs.c
        quickjs-libc.c
        libbf.c
        libregexp.h
        libregexp-opcode.h
        libunicode.h
        libunicode-table.h
        list.h
        quickjs.h
        quickjs-atom.h
        quickjs-libc.h
        quickjs-opcode.h)

add_library(libquickjs STATIC ${qjs_src})

target_compile_definitions(libquickjs PUBLIC JS_STRICT_NAN_BOXING=1 CONFIG_BIGNUM=1)
target_include_directories(libquickjs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_library(libquickjs-dumpleaks STATIC ${qjs_src})
target_compile_definitions(libquickjs-dumpleaks PRIVATE DUMP_LEAKS=1)
target_compile_definitions(libquickjs-dumpleaks PUBLIC JS_STRICT_NAN_BOXING=1 CONFIG_BIGNUM=1)
target_include_directories(libquickjs-dumpleaks PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})


add_executable(qjsc qjsc.c)
target_link_libraries(qjsc libquickjs)

add_executable(qjs qjs.c repl.c qjscalc.c)
target_link_libraries(qjs libquickjs)